using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using DAL;
using Entities;
using Utility;

public partial class KhachHang_Chitietsanpham : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadData();
    }

    private void LoadData()
    {
        //tbHinhAnh.tbHinhAnhCollection ha_collection = tbHinhAnhBus.GetByIDSP(24);
        //Repeater1.DataSource = ha_collection;
        //Repeater2.DataSource = ha_collection;

        //Repeater1.DataBind();
        //Repeater2.DataBind();

        Criteria cri = new Criteria();
        int id = int.Parse(Request.QueryString["id"].ToString());
        cri.add(Condition.AND, tbHinhAnh.tbHinhAnhColumns.IDSanPham.ToString(), Condition.EQUAL, tbSanPham.tbSanPhamColumns.IDSanPham.ToString());

        tbHinhAnh.tbHinhAnhCollection hacollection = tbHinhAnhBus.GetByIDSP(id);
        Repeater1.DataSource = hacollection;
        Repeater2.DataSource = hacollection ;

        Repeater1.DataBind();
        Repeater2.DataBind();

    }

    protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
            e.Item.ItemType == ListItemType.Item)
        {
            tbHinhAnh hh = (tbHinhAnh)e.Item.DataItem;
            Image img_hinhanh = (Image)e.Item.FindControl("img_hinhanh");
            img_hinhanh.ImageUrl = "~/Admin/Photos/" + hh.TenHinh.ToString();
            Image img1 = (Image)e.Item.FindControl("img1");
            img1.ImageUrl = "~/Admin/Photos/" + hh.TenHinh.ToString();
        }
    }
}
